package com.jf.blog_jf04.controller;

import com.jf.blog_jf04.data.PageInfo;
import com.jf.blog_jf04.data.ov.CommentSearchOV;
import com.jf.blog_jf04.service.CommentService;
import com.jf.blog_jf04.utils.R;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RequestMapping("/comment")
@RestController
@Api(tags = "评论模块")
public class CommentController {
    @Autowired
    private CommentService commentService;

    @GetMapping("/page")
    @ApiOperation("分页筛选")
    public R page(PageInfo pageInfo, CommentSearchOV form) {
        return commentService.getPage(pageInfo, form);
    }

    @PostMapping("/update/status/{commentId}")
    @ApiOperation("修改状态")
    public R status(@ApiParam("评论编号") @PathVariable int commentId) {
        commentService.updateStatus(commentId);
        return R.success();
    }

    @DeleteMapping("/delete")
    @ApiOperation("批量删除")
    public R delete(@ApiParam("批量删除id") @RequestParam List<Integer> ids) {
        commentService.removeByIds(ids);
        return R.success();
    }
}
